<?php
include "includes/sesiones.php";
include "includes/comunes.php";

$men="";
//foreach($_POST as $nombre_campo => $valor)
//{
//  echo  '$' . $nombre_campo . '=\'' . $valor . '\';<br />';
//}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script languaje='javascript' type='text/javascript'>
function confirmar(){

         var seleccion = confirm("Esta seguro que desea confirmar el monto ingresado?");

if (seleccion)
 document.form1.submit();
else
return seleccion;
       
        }
    </script>


     <script languaje='javascript' type='text/javascript'>
     function recarga_padre_y_cierra_ventana(){
        window.opener.location.reload();
        window.close();
        }
    </script>
<?php

 if($_POST['pagos']==1):
   registrar_pago($_POST['cre_id'],$_POST['cuota'],$_POST['pun'],$_POST['saldo'],$_POST['tot']);
 endif
?>

<?php include "includes/metas.php";?>
</head>
<body>

<div class="contenedor">
	<div class="cont" style="width: 600px; float: left;">
    	
    	
        	<div class="novedadestitulo">
            	<div class="novetitulo2">Pago de Cuota Nº <?php echo $_GET['cuota']?> del credito <?php echo $_GET['cre_id']?></div>
            </div>
            <span style="color:red;float:left;font-size:14px;font-weight:bold;font-family:Arial, Helvetica, sans-serif;"><?php echo $men;?></span>
             <form id="form1" name="form1" method="post" action="pagar.php?cuota=<?php echo $_GET['cuota']?>&cre_id=<?php echo $_GET['cre_id']?>">
<?php
 if(!$_POST['pagos']==1):?>
 <table width="595" border="0" style="float:left;
		font-size:14px;
		font-weight:bold;
		font-family:Arial, Helvetica, sans-serif;">
  <tr>
    <td width="133"><div align="left">Total de Cuota </div></td>
    <td width="139"><div align="left"> <h3>$ <?php echo round(number_format($_GET['total'],2, '.', ''));?></h3></div></td>
    <td width="157"><div align="left">Fec. Ultimo Pago </div></td>
    <td width="148"><h3><?php echo obtener_fecha_ultimo_pago($_GET['cre_id'],$_GET['cuota'])?></h3></td>
  </tr>
  <tr>
    <td><div align="left"></div></td>
    <td><div align="left"></div></td>
    <td><div align="left"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="left">Abonado a la Fecha </div></td>
    <td><div align="left"><h3>$ <?php echo round(sumar_recibos($_GET['cre_id'],$_GET['cuota']));?></h3></div></td>
    <td><div align="left">Saldo de Cuota </div></td>
    <td><h3>$ <?php echo round(obtener_saldo($_GET['cre_id'],$_GET['cuota']))?></h3></td>
  <input name="saldo" class="bot" type="hidden" value=" <?php echo round((number_format($_GET['total'],2, '.', '')-sumar_recibos($_GET['cre_id'],$_GET['cuota'])))?>" />
  </tr>
  <tr>
    <td><div align="left"></div></td>
    <td><div align="left"></div></td>
    <td><div align="left"></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="left">Total Punitorios </div></td>
    <td><div align="left">
            <input name="puni" class="bot" type="text" value="<?php echo round($_GET['pun'])?>" disabled/>
            <input name="pun" class="bot" type="hidden" value="<?php echo round($_GET['pun'])?>"/>
                 <input name="cre_id" class="bot" type="hidden" value="<?php echo $_GET['cre_id'];?>" />
                  <input name="cuota" class="bot" type="hidden" value="<?php echo $_GET['cuota'];?>" />
             <input name="total" class="bot" type="hidden" value="<?php echo round($_GET['total']);?>" /></div></td>
    <td><div align="left">Total a Abonar </div></td>

    <td><input name="tot" class="bot"  style="color:red;font-size: 16px;" type="text" value=" <?php echo round($_GET['pun']+obtener_saldo($_GET['cre_id'],$_GET['cuota']));?>" /></td>
  </tr>
  <tr>
      <td colspan="4" align="center">
<!--          <div style="float:left; border-left: 30px;"><br>
              <button class="bot"  onclick="Shadowbox.close()" value="Cancelar" style="width:200px; background-color: red;border-left: 300px;">
                  Cancelar</button></div>-->
   <input name="pagos" class="bot" type="hidden" value="1" />
 <div style="float: right;"><br> <input name="pagar" class="bot"  type="button" value="Pagar"  onclick="confirmar();" style="width:200px; background-color: green;border-left: 300px;"/><br></br></div></td>
    </tr>
	
	<tr>
    <td colspan="4"><div align="center">
   <table width="450" border="0" style="border: 1px solid #ccc;">
  <tr style="border: 1px solid #ccc; background-color: #ddd;">
    <td colspan="3"><div align="center">Detalles de Pagos Asociados </div></td>
  </tr>
   <tr style="border: 1px solid #ccc; background-color: #ddd;">
    <td align="center">Recibo Nº</td>
    <td align="center">Fecha de Pago</td>
    <td align="center">Monto Abonado</td>
  </tr>
  <?php
  $sqlRec="select * from recibos where credito=".trim($_GET['cre_id'])." and cuota=".trim($_GET['cuota'])." order by Id desc";
  $resrec=  cons_ins($sqlRec);
  while ($regdet=mysql_fetch_array($resrec)):
  ?>              
  <tr>
      <td align="center"><?php echo $regdet['Id']?></td>
    <td align="center"><?php echo $regdet['fecha']?></td>
    <td align="center"><?php echo round($regdet['pagado']+$regdet['punitorios'])?></td>
    
  </tr>
  <?php
  
  endwhile
  ?>
</table>

        </div></td>
    </tr>
</table>
<?php
else: ?>

<table width="500" height="100" border="0" align="center" style="float:left;
		font-size:14px;
		font-weight:bold;
		font-family:Arial, Helvetica, sans-serif;">
  <tr>
    <td width="131">Credito</td>
    <td width="106">&nbsp;<?php echo $_POST['cre_id']?></td>
    <td width="139">Cuota Abonada </td>
    <td width="112">&nbsp; <?php echo $_POST['cuota']?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>Monto Abonado </td>
    <td>&nbsp;$ <?php echo $_POST['tot']?></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="4">

        <div align="center">
            <a  href="ImprimirPagoCuota.php?cre_id=<?php echo $_GET['cre_id'];?>&cuota=<?php echo $_GET['cuota'];?>"  target="_blank"  style="width:200px; border-left: 300px;">
                <img src="images/imprimir.png" border="0"/></a>
        </div></td>
    </tr>
</table>




<div align="center">
  <?php
endif ?>
  
  
  
  
  
</div>
             </form>
    
        	<div class="novedadesbottom"></div>
 

    
	<div id="clearing"></div>    
    </div>
<div id="clearing"></div>
</div>
<p>
</p>
</body>
</html>
